package band.wukong.practice.springboot.spring4.mvc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.async.DeferredResult;

/**
 * @author wukong(wukonggg@139.com)
 */
@Controller
@RequestMapping("/async")
public class AsyncController {

    @Autowired
    AsyncPushService service;

    @RequestMapping({"", "/toDefer"})
    public String index() {
        return "defer";
    }

    @RequestMapping("/defer")
    @ResponseBody
    public DeferredResult<String> deferredCall() {
        return service.getAsyncUpdate();
    }
}
